<template>
  <div class="app-container">
    <el-form  :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="阶段" prop="stage">
        <el-select v-model="queryParams.stage" placeholder="请选择阶段" clearable>
          <el-option
            v-for="dict in dict.type.sys_stage"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="planList">
      <el-table-column label="日期" align="center" prop="date" fixed="left">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.date, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="班级名字" align="center" prop="className" />
      <el-table-column label="阶段" align="center" prop="stage" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_stage" :value="scope.row.stage"/>
        </template>
      </el-table-column>
      <el-table-column label="周几" align="center" prop="weekday">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.ya_weekday" :value="scope.row.weekday"/>
        </template>
      </el-table-column>
      <el-table-column label="第几天" align="center" prop="day" />
      <el-table-column label="授课内容" align="center" prop="courseContent" />
      <el-table-column label="备注" align="center" prop="remarks" />
    </el-table>

    <pagination
      v-show="total>0"
      :page-sizes="[200,500]"
      :page-size="200"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<style>
.el-table .warning-row {
  background: #34bfa3;
}

.el-table .success-row {
  background: #f0f9eb;
}

.el-table .yellow-row {
  background: #e6a700;
}
</style>
<script>
import {list_MyPlan} from "@/api/teaching/teaching_plan";

export default {
  name: "Plan",
  dicts: ['sys_stage','ya_attendance_status','ya_weekday','ya_task_status','ya_task_qualified'],
  data() {
    return {
      isEdit: false, // 新增一个标志位，用于判断是新增还是修改
      drawer: false,
      direction: 'ltr',
      interviewList:[],
      baseUrl: process.env.VUE_APP_BASE_API,
      planId:null,
      completionList:[],
      completionOpen:false,
      completionLoading:false,
      completionForm: {},
      //学员考勤信息
      studentAttendanceList:[],
      classesList: [],
      courseList: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 教学课表(课表)表格数据
      planList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      tracking_open:false,
      attendance_open:false,
      trackingForm:{},
      attendanceForm:{},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 180,
        date: null,
        day: null,
        courseContent: null,
        classNames: [],
        stage: null // 初始化为null，这样下拉框不会显示默认值
      },
      defaultStage: 1, // 新增一个变量来存储默认的stage值
      interviewForm: {
      },
      generationDisabled:true,
      planAllList:[]
    };
  },
  created() {
    // 在组件创建时，使用默认的stage值进行首次查询
    this.queryParams.stage = this.defaultStage;
    this.getList();
  },
  methods: {
    /** 查询我的课表 */
    getList() {
      this.loading = true;
      let data = { stage: this.queryParams.stage }
      list_MyPlan(data).then(response => {
        this.planList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    cancelTrackingForm() {
      this.tracking_open = false;
      this.resetTrackingForm();
    },
    cancelAttendanceForm() {
      this.attendance_open = false;
      this.resetAttendanceForm();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        date: null,
        day: null,
        courseContent: null,
        remarks: null,
        className: null,
        stage: null,
        beginDate: ""
      };
      this.resetForm("form");
      this.planAllList = [];
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    onOpen() {
    },
    onClose() {
      this.$refs['form'].resetFields()
    },
    close() {
      this.$emit('update:visible', false)
    },
  }
};
</script>
